#!/usr/bin/env python

import sys
import optparse

from lazarus.datastore import datastore
from lazarus.lazarus import lazarus

def main():
  commands = ['backup', 'restore']
  hidden_commands = ['dump', 'history']
  usage = 'usage: %prog <' + '|'.join(commands) + '>'
  parser = optparse.OptionParser(usage=usage)
  parser.add_option("--prefix",
                    dest="session_prefix",
                    help="prefix to use for restored session names",
                    default='',
                    metavar="PREFIX")
  options, args = parser.parse_args()

  if len(args) == 0 or (args[0] not in commands and args[0] not in hidden_commands):
    parser.print_help()
    sys.exit(1)

  with datastore() as data:
    l = lazarus(data)
    l.handle_command(options, args)

if __name__ == '__main__':
  main()
